package com.xjc.business.controller.classadmin;

import com.xjc.business.entity.vo.PageVo;
import com.xjc.business.entity.vo.classadmin.ClassVo;
import com.xjc.business.service.ClazzsService;
import com.xjc.system.constants.MyConstants;
import com.xjc.system.exception.MyException;
import com.xjc.system.result.Result;
import com.xjc.system.result.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 徐锦程
 * 时间:2025-01-31 8:31
 */
@RestController
@RequestMapping("/class_admin/class")
public class ClassController {

    @Autowired
    ClazzsService clazzsService;

    /**
     * 查询班级信息
     * @param classAdminId 辅导员id
     * @param majorId 专业id
     * @return 数据
     */
    @GetMapping("/page/{classAdminId}/{majorId}")
    public Result<List<ClassVo>> getClassPage(
            @PathVariable(value = "classAdminId",required = false) Integer classAdminId,
            @PathVariable(value = "majorId",required = false) Integer majorId
    ){

        if(majorId == null){
            majorId = -1;
        }

        if(classAdminId == null){
            throw new MyException(ResultCode.SUCCESS.getCode(), MyConstants.PARAM_MISSING);
        }

        return clazzsService.getClassPage2(classAdminId,majorId);
    }
}
